<!DOCTYPE HTML>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,aItemress=no">
	<link rel="stylesheet" type="text/css" href="../css/aui.css" />
	<link rel="stylesheet" type="text/css" href="../css/swiper.min.css" />
	<link rel="stylesheet" type="text/css" href="../css/app.css" />
	<title>home</title>
	<style type="text/css">
		body {
			background: #fafafa !important;
		}

		.aui-bar-nav {
			z-index: 100;
			top: -1px;
		}

		.swiper-pagination {
			bottom: 0.3rem;
			width: 100%;
		}

		.swiper-pagination-bullet {
			width: 0.2rem;
			height: 0.2rem;
			margin-right: 0.3rem;
			background: #FFFFFF;
			opacity: 0.46;
		}

		.swiper-pagination-bullet-active {
			background: #FFFFFF;
			opacity: 1;
		}

		.menu .aui-col-xs-3 img {
			width: 2.6rem;
			display: inline-block;
		}

		.aui-grid [class*=aui-col-] {
			padding: 0.45rem 0;
		}

		.aui-grid {
			padding: 0.45rem 0;
		}

		.aui-grid .aui-grid-label {
			font-size: 0.65rem;
		}

		/*商品列表*/

		.goods-list .aui-col-xs-6 .goods-content {
			position: relative;
			overflow: hidden;
			border-radius: 5px;
			box-shadow: 1px 1px 6px 1px RGBA(246, 244, 244, 0.81);
		}

		.goods-list .aui-ellipsis-2 {
			height: 2.5rem;
		}

		.goods-list .aui-col-xs-6:nth-child(2n+0) {
			padding-left: 0.25rem;
			margin-bottom: 0.5rem;
		}

		.goods-list .aui-col-xs-6:nth-child(2n+1) {
			padding-right: 0.25rem;
			margin-bottom: 0.5rem;
		}

		.goods-tag {
			color: RGBA(255, 88, 49);
			font-size: 10px;
			border: 1px solid RGBA(255, 88, 49);
			border-radius: 5px;
			padding: 0 6px;
			white-space: nowrap;
			margin: 3px 0;
			margin-right: 5px;
			display: inline-block;
			height: 16px;
			line-height: 16px;
		}

		.goods-price {
			color: RGBA(255, 88, 49);
			font-size: 13px;
		}

		.goods-tag-corner {
			position: absolute;
			width: 40px;
			height: 40px;
			line-height: 23px;
			text-align: center;
			background-color: #FF3862;
			color: #FFFFFF;
			transform: rotateZ(-45deg);
			font-size: 8px;
			top: -20px;
			left: -20px;
		}

		/*下划线判断*/

		.active_line {
			width: 12.5rem;
			/*height:5.95irem;*/
			line-height: 1.1rem;
			float: left;
			margin-bottom: 0.9rem;
			padding-bottom: 0;
			/*border: 1px solid blue;*/
			/*padding-left: 0.3rem;*/
		}

		/*新品速递改写*/

		.newproduct {
			height: 2.65rem;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 0.75rem;
			margin-top: 0.3rem;
		}

		.new_wraper {
			padding: 0 0.75rem;
		}

		.newproduct_left {
			/* background: url();
			background-repeat: no-repeat;
			background-size: auto 0.8rem;
			background-position: left center; */
			padding-left: 10px;
			display: inline-block;
			font-size: 0.9rem;
			/* font-family: PingFangSC-Semibold; */
			font-weight: 600;
			color: rgba(51, 51, 51, 1);
			margin-bottom: -0.5rem
		}

		.newproduct_right span {
			font-size: 0.7rem;
			/* font-family: PingFangSC-Regular; */
			font-weight: 400;
			color: rgba(102, 102, 102, 1);
		}

		.newproduct_list {
			/*height: 6.75rem;*/
			background: rgba(255, 255, 255, 1);
			padding: 0.5rem;
			box-sizing: border-box;
			border-radius: 0.4rem;
			margin-top: 0.5rem
		}

		.left_img {
			width: 5rem !important;
			height: 5rem !important;
			margin-right: 0.75rem;
			position: relative;
		}

		.left_img img {
			width: 100%;
			border-radius: 0.2rem;
		}

		.left_img .sign {
			position: absolute;
			left: 0;
			bottom: 0;
			width: 43px;
			height: 18px;
			background: #4385EA;
			border-radius: 0px 4px 0px 4px;
		}

		.left_img .sign .sign_title {
			width: 24px;
			height: 12px;
			font-size: 12px;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			line-height: 18px;
			text-align: center;
			margin: auto;
			vertical-align: center
		}

		.right_cont {}

		.top_title {}

		.top_title img {
			width: 1.6rem;
			height: 0.9rem;
			display: inline-block;
			transform: translateY(0.15rem);
			margin-right: 0.2rem;
		}

		.top_title {
			font-size: 0.7rem;
			/* font-family: PingFangSC-Regular; */
			font-weight: 400;
			color: #222222;
			line-height: 1.1rem;
			max-height: 2.2rem;
			display: inline-block;
		}

		.title {
			text-overflow: -o-ellipsis-lastline;
			overflow: hidden;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-line-clamp: 2;
			line-clamp: 2;
			-webkit-box-orient: vertical;
		}

		.mid_decri {
			/*display: flex;*/
		}

		.mid_decri_item {
			padding: 0 0.1rem;
			line-height: 0.75rem;
			border-radius: 0.1rem;
			border: 0.05rem solid #005a93;
			font-size: 0.55rem;
			border-radius: 0.1rem;
			/* font-family: PingFangSC-Regular; */
			font-weight: 400;
			color: #005a93;
			/*text-align: center;*/
			float: left;
			margin-top: 0.3rem;
			margin-right: 0.25rem;
			margin-bottom: 0.4rem;
			padding-top: 0.010rem;
			background: rgba(239, 249, 255, 0.4);
		}

		.clear {
			clear: both;
		}

		.now_price {
			font-size: 1.1rem;
			/* font-family: 'PingFangSC-Semibold'; */
			font-weight: 600;
			color: #e90000;
			line-height: 1rem;
		}

		.swiper-pagination-bullet-active {
			/*width: 0.5rem;
			height: 0.25rem;
			background: rgba(255, 255, 255, 1);
			border-radius: 0.1rem;*/
		}

		.bottom_miao {
			margin-bottom: 1rem;
		}

		.btn_refresh {
			width: 10rem;
			height: 2rem;
			background: linear-gradient(135deg, rgba(132, 229, 255, 1) 0%, rgba(107, 180, 255, 1) 100%, rgba(122, 174, 229, 1) 100%);
			border-radius: 1.23rem;
			font-size: 0.8rem;
			/* font-family: PingFangSC-Regular; */
			font-weight: 400;
			color: rgba(255, 255, 255, 1);
			margin: 0 auto;
			margin-top: 2rem;
			line-height: 2rem;
			text-align: center;
		}

		.zq {
			width: 50%;
			float: left;
		}

		.headline {
			position: relative;
		}

		.headline span {
			display: inline-block;
			position: absolute;
			top: 0.5rem;
			color: #fff;
			font-weight: bold;
			left: 35%;
			margin-left: 0.5rem
		}

		.item {
			background: #fafafa
		}

		.item .pic img {
			border-bottom-left-radius: 0.2rem;
			border-bottom-right-radius: 0.2rem;
		}

		.newproduct_right img {
			width: 0.46rem;
			margin-left: 0.15rem
		}

		.bg {
			/*background: url(../image/bg/index_bg.png) center;*/
			/*background-size: cover;
			background-repeat: no-repeat;*/
			width: 100%;
			/*margin-top: -3rem;*/
			/*transition: all 0.1s linear;*/
			/*padding-top: 0.5rem;*/
			position: relative;
		}

		.item .w1 {
			font-weight: normal;
			width: 2rem;
			height: 0.05rem;
			background: rgba(255, 255, 255, 0.5);
			position: absolute;
			display: inline-block;
			top: 1rem;
			left: 1.1rem
		}

		.item .circle {
			display: inline-block;
			background: #fff;
			border-radius: 50%;
			width: 0.15rem;
			height: 0.15rem;
			position: absolute;
			left: 3rem;
			top: 0.96rem;
		}

		.w1.cc {
			left: 5.6rem;
		}

		.circle.yu {
			left: 5.6rem;
		}

		.aui-bar-nav {
			background: transparent;
			position: fixed;
			transition: all 0.1s linear;
			padding: 1rem 0 0.3rem
		}

		.aui-bar-nav .aui-pull-left {
			height: 1.7rem;
			line-height: 1.7rem;
			background-color: #F5F5F5;
			border-radius: 0.25rem;
			margin-top: 0.275rem;
			width: 8.5rem;
			margin-left: 0.02rem;
		}

		.header {
			padding: 0.5rem 0
		}

		.address {
			display: flex;
			justify-content: flex-start;
			width: 250rpx;
		}

		.ade {
			margin-top: 0.5rem;
			padding: 0px 0.75rem;
			background: rgb(250, 250, 250) !important;
		}

		.ade img {
			width: 100%;
		}

		.ico {
			display: inline-block;
			width: 0.8rem;
			height: 0.8rem;
			line-height: 1.0rem;
			margin-left: 0.3rem;
		}
	</style>
</head>

<body>
	<div id="app">
		<template class="" v-if="isnetwork">
			<div class="bg">
				<img :src="index_bg">
			</div>
			<div class="header" style="margin-top:2em">

				<div class="aui-bar aui-bar-nav aui-padded-l-15 aui-padded-r-15 flex-box-x"
					style="padding-top:2.5rem;dislay:flex">
					<!-- <div class="flex-box-y"> -->
					<div class="" onclick="open_location()"
						style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis;width:5.5rem;">
						<!-- <span v-if="localcity.regionname && (localcity.regionname.indexOf('县')!==-1 || localcity.regionname.indexOf('市')!==-1)">{{localcity.regionname}}</span> -->
						<div style="display:flex;justify-content:center;align-items:center">
							<span v-if="localcity">{{localcity.categoryname}}</span>
							<span v-else>选择定位</span>
							<img class="ico" src="../image/svg/ico_local.png" alt="">
						</div>
					</div>

					<div class="aui-pull-left" style="border-radius:1.5rem; position: relative;" tapmode
						onclick="openWin_Search()">
						<img style="width:0.5rem;height:0.7rem;display: inline-block;margin-left:0.5rem;margin-right:0.25rem"
							src="../image/btn/btn-search-new.svg" />
						<span
							style="font-size: .65rem;color: #BBBBBB;font-family:PingFangSC-Regular;font-weight:400;">输入关键字</span>
					</div>

					<a class="aui-pull-right" style="padding: 0 0.25rem;" tapmode
						onclick="open_win('my_score', './score/index.html', false)"
						style="transform:translateX(-.2rem);">
						<img style="width: 1.1rem;height:1.1rem;" src="../image/btn/btn-index-qiandao.png" />
					</a>

					<a class="aui-pull-right" style="padding: 0 0.25rem;" tapmode onclick="open_message()"
						style="transform:translateX(-.2rem);">
						<img style="width: 1.1rem;height:1.1rem;" src="../image/btn/btn-index-message.png" />
						<div v-if="login_status==true && unread_msg_num > 0" class="aui-dot"
							style="position:absolute;right:0.9rem;top:2.5rem;">
						</div>
					</a>
					<!-- </div> -->



				</div>
			</div>
			<div style="margin-top:-5.3rem">
				<div class="swiper-container">
					<div class="swiper-wrapper" style="">
						<div v-cloak
							style="display:flex;justify-content:center;box-shadow:0rem 0.1rem 0.3rem rgba(51, 51, 51, 0.3);"
							v-for="vo in banner_ad" class="swiper-slide" tapmode @click="openbanner(vo)">
							<!-- margin:0.5rem 0.75rem 0 0.75rem; -->
							<img :src="vo.pic"
								style="width:17.25rem;height:7.5rem;margin-top:0.5rem;border-radius:0.6rem;box-shadow:0px 0.1rem 0.6rem rgba(0,0,0,0.05);" />
						</div>
					</div>
				</div>
				<div class="swiper-pagination"></div>
			</div>

			<div class="aui-grid menu" style="background:#fafafa;margin-top:0.5rem">
				<div class="aui-row">

					<div v-cloak v-for="vo in good_type" class="aui-col-xs-3 aui-padded-l-10"
						style="width:20%; text-align: center;" tapmode @click="open_class_goods_list(vo.id)">

						<img :src="vo.icon_path" style="transform:translateX(-.25rem);width:2.5rem;height:2.5rem;" />
						<div
							style="transform:translateX(-.25rem);color:#444444;font-size:0.60rem;font-family:PingFangSC-Regular;font-weight:400;">
							{{vo.name}}</div>
					</div>
				</div>
			</div>


			<!-- <div class="lh10"></div> -->
			<div class="ming-bg-white flex-box-x ade"
				style="margin-top:0.5rem;padding:0 0.75rem;background:#fafafa !important">
				<div class="item col-xs-x"
					onclick="open_win('miaosha_goods_list','goods/miaosha_goods_list.html',false)">
					<div class="headline">
						<img src="../image/bg/index_area_bg_0.png" alt="">
						<span>秒杀</span>
						<b class="w1"></b><em class="circle"></em>
						<b class="w1 cc"></b><em class="circle yu"></em>
					</div>
					<div class="pic">
						<img :src="index_ad[0]&&index_ad[0].pic" alt="" srcset="">
					</div>

				</div>
				<div style="width: 0.75rem;"></div>
				<div class="item col-xs-x" onclick="open_win('group_goods_list','goods/group_goods_list.html',false)">
					<div class="headline">
						<img src="../image/bg/index_area_bg_1.png" alt="">
						<span>拼团</span>
						<b class="w1"></b><em class="circle"></em>
						<b class="w1 cc"></b><em class="circle yu"></em>
					</div>
					<div class="pic">
						<img :src="index_ad[1]&&index_ad[1].pic" alt="" srcset="">
					</div>

				</div>
				<div class="aui-clearfix"></div>
			</div>
			<!-- <div class="lh10"></div> -->
			<template v-if="xp_good.length>0 || qc_good.length>0 || jp_good.length>0">
				<!-- 新品速递 -->
				<div v-if="xp_good.length>0" class="newproduct flex-box-x" tapmode
					@click="openWin_goods_list_type(xp_good[0].sign)">
					<div class="newproduct_left col-xs-x flex-y-center">
						<span>{{xp_good[0].sign}}</span>
					</div>
					<div class="newproduct_right flex-y-center">
						<span>更多</span>
						<img src="../image/icon/right_turn_new.png" alt="">
					</div>
				</div>
				<div class="new_wraper">
					<div class="newproduct_list flex-box-x" v-for="(vo, index) in xp_good" tapmode
						@click="openWin_goods_detail(vo.id)">
						<div class="left_img">
							<img :src="vo.cover" alt="">
							<div class="sign" v-if="vo.sign">
								<div class="sign_title" v-html="vo.sign"></div>
							</div>
						</div>
						<div class="right_cont col-xs-x">
							<div class="top_title title">
								<!-- <img src="../image/icon/xinpin.png" alt="">  -->
								{{vo.title}}
							</div>
							<div class="mid_decri" v-for="item in vo.service_name">
								<div class="mid_decri_item">{{item}}</div>
							</div>
							<section class="clear"></section>
							<div>
								<div>
									<span class="" style="font-size: .6rem;color:#005a93;">零售价:￥<span class=""
											style="font-size:0.9rem;color:#005a93;line-height:1.35rem;">{{vo.current_price}}</span><span
											style="font-size:.65rem">/{{vo.unit_name}}</span></span>
									<!-- <del style="color:rgba(153,153,153,.7);font-size: .65rem;font-weight:400;">￥{{vo.cost_price}}</del> -->
								</div>

								<div v-if="vo.vip_show>0">
									<span class="" style="font-size: .6rem;color:#e90000;">会员价:￥<span class=""
											style="font-size:1.2rem;color:#e90000;line-height:1.35rem;">{{price_format('yuan',vo.vip_price)}}</span><span
											class=""
											style="font-size:0.9rem;">.{{price_format('fen',vo.vip_price)}}</span><span
											style="font-size:.65rem">/{{vo.unit_name}}</span></span>
								</div>


							</div>
						</div>
					</div>
				</div>
				<!-- 热销产品 -->

				<div v-if="qc_good.length>0">
					<div class="newproduct flex-box-x" tapmode @click="openWin_goods_list_type(qc_good[0].sign)">
						<div class="newproduct_left col-xs-x">
							<span>{{qc_good[0].sign}}</span>
						</div>
						<div class="newproduct_right flex-y-center">
							<span>更多</span>
							<img src="../image/icon/right_turn_new.png" alt="">
						</div>
					</div>
					<div class="new_wraper">
						<div class="newproduct_list flex-box-x" v-for="vo in qc_good" tapmode
							@click="openWin_goods_detail(vo.id)">
							<div class="left_img">
								<img :src="vo.cover" alt="">
								<div class="sign" v-if="vo.sign">
									<div class="sign_title" v-html="vo.sign"></div>
								</div>
							</div>
							<div class="right_cont col-xs-x">
								<div class="top_title title">
									<!-- <img src="../image/icon/qingcang.png" alt=""> -->
									{{vo.title}}
								</div>
								<div class="mid_decri" v-for="item in vo.service_name">
									<div class="mid_decri_item">{{item}}</div>
								</div>
								<section class="clear"></section>
								<div>
									<div>
										<span class="" style="font-size: .6rem;color:#4385EA;">零售价:￥<span class=""
												style="font-size:0.9rem;color:#4385EA;line-height:1.35rem;">{{vo.current_price}}</span><span
												style="font-size:.65rem">/{{vo.unit_name}}</span></span>
										<!-- <del style="color:rgba(153,153,153,.7);font-size: .65rem;font-weight:400;">￥{{vo.cost_price}}</del> -->
									</div>

									<div v-if="vo.vip_show>0">
										<span class="" style="font-size: .6rem;color:#e90000;">会员价:￥<span class=""
												style="font-size:1.2rem;color:#e90000;line-height:1.35rem;">{{price_format('yuan',vo.vip_price)}}</span><span
												class=""
												style="font-size:0.9rem;">.{{price_format('fen',vo.vip_price)}}</span><span
												style="font-size:.65rem">/{{vo.unit_name}}</span></span>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>

				<!-- 精品推荐 -->
				<div v-if="jp_good.length>0">
					<div class="newproduct flex-box-x" tapmode @click="openWin_goods_list_type(jp_good[0].sign)">
						<div class="newproduct_left col-xs-x">
							<span>{{vm.jp_good[0].sign}}</span>
						</div>
						<div class="newproduct_right flex-y-center">
							<span>更多</span>
							<img src="../image/icon/right_turn_new.png" alt="">
						</div>
					</div>
					<div class="new_wraper">
						<div class="newproduct_list flex-box-x" v-for="vo in jp_good" tapmode
							@click="openWin_goods_detail(vo.id)">
							<div class="left_img">
								<img :src="vo.cover" alt="">
								<div class="sign" v-if="vo.sign">
									<div class="sign_title" v-html="vo.sign"></div>
								</div>
							</div>
							<div class="right_cont col-xs-x">
								<div class="top_title title">
									<!-- <img src="../image/icon/tuijian.png" alt=""> -->
									{{vo.title}}
								</div>
								<div class="mid_decri" v-for="item in vo.service_name">
									<div class="mid_decri_item">{{item}}</div>
								</div>
								<section class="clear"></section>
								<div>
									<div>
										<span class="" style="font-size: .6rem;color:#4385EA;">零售价:￥<span class=""
												style="font-size:0.9rem;color:#4385EA;line-height:1.35rem;">{{vo.current_price}}</span><span
												style="font-size:.65rem">/{{vo.unit_name}}</span></span>
										<!-- <del style="color:rgba(153,153,153,.7);font-size: .65rem;font-weight:400;">￥{{vo.cost_price}}</del> -->
									</div>

									<div v-if="vo.vip_show>0">
										<span class="" style="font-size: .6rem;color:#e90000;">会员价:￥<span class=""
												style="font-size:1.2rem;color:#e90000;line-height:1.35rem;">{{price_format('yuan',vo.vip_price)}}</span><span
												class=""
												style="font-size:0.9rem;">.{{price_format('fen',vo.vip_price)}}</span><span
												style="font-size:.65rem">/{{vo.unit_name}}</span></span>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</template>
			<template v-else style="height:100%;text-align:center;">
				<div v-if="localcity">
					<img src="../image/icon/nonetwork.png" alt=""
						style="width:5.5rem;margin:0.4rem auto;margin-bottom:0.5rem;">
					<div class=""
						style="font-size:0.75rem;font-family:PingFangSC-Regular;font-weight:400;color:rgba(34,34,34,1);line-height:1.05rem;text-align:center;">
						抱歉，该区域当前还未覆盖，敬请期待！
					</div>
				</div>
			</template>

		</template>
		<template id="" v-else style="height:100%;text-align:center">
			<img src="../image/icon/nonetwork.png" alt=""
				style="width:5.5rem;margin:11.4rem auto;margin-bottom:0.5rem;">
			<div class=""
				style="font-size:0.75rem;font-family:PingFangSC-Regular;font-weight:400;color:rgba(34,34,34,1);line-height:1.05rem;text-align:center;">
				暂无网络
			</div>
			<div class="btn_refresh" tapmode onclick="refresh_network()">
				刷新
			</div>
		</template>
	</div>
</body>

<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/swiper.min.js"></script>
<script type="text/javascript" src="../script/aui-actionsheet.js"></script>
<script type="text/javascript">
	//		商品价格现价没有取活动价格
	var vm = new Vue({

		el: '#app',
		data: {
			index_bg: [],
			banner_ad: [],
			index_ad: [],
			xp_good: [],
			qc_good: [],
			jp_good: [],
			good_type: [],
			has_tuan: 0,
			has_miao: 0,
			isnetwork: true,
			currentShow: false,
			login_status: false,
			unread_msg_num: 0,
			loadmore: false,
			localcity: { "id": 2608, "parentid": 235, "categoryname": "平邑县", "spell": "pingyixian", "first_letter": "P" },
			is_show: false,
			agree: false
		},
		mounted() {

			window.addEventListener("scroll", this.showIcon);

		},

		methods: {
			openMsgbox: function () {
				api.openFrame({
					name: 'yinsi_msgbox',
					url: 'widget://html/login/components/msgbox.html',
					bounces: false,
					vScrollBarEnabled: false,
					bgColor: 'rgba(0,0,0,0.5)',
					rect: {
						x: 0,
						y: 0,
						w: 'auto',
						h: 'auto'
					},
					pageParam: {}
				})
			},
			// 打开外链app浏览器
			openbanner(vo) {

				//	无链接有广告内容
				if (vo.flag == 1) {
					$api.setStorage('banner_content', vo)
					open_win('banner', 'widget://html/page/banner.html', false)
				}
				//	外链接
				if (vo.flag == 2) {
					// 打开外部链接
					api.openWin({
						useWKWebView: true,
						name: 'browser',
						url: 'widget://html/browser.html',
						bounces: false,
						pageParam: {
							url: vo.url,
							name: '链接'
						}
					});
					// if (api.systemType != 'android') {
					// 	api.openApp({
					// 		iosUrl: vo.url //打开应用设置界面，支持iOS 8及以上系统
					// 	});
					// } else {
					// 	api.openApp({
					// 		androidPkg: 'android.intent.action.VIEW',
					// 		mimeType: 'text/html',
					// 		uri: vo.url
					// 	}, function(ret, err) {
					// 		if (ret) {
					// 			// alert(JSON.stringify(ret));
					// 		} else {
					// 			// alert(JSON.stringify(err));
					// 		}
					// 	});
					// }
				}
				//	商品链接
				if (vo.flag == 3) {
					openWin_goods_detail(vo.url)
				}
				//	秒杀
				if (vo.flag == 4) {
					open_win('miaosha_goods_list', 'widget://html/goods/miaosha_goods_list.html', false)
				}
				//	团购
				if (vo.flag == 5) {
					open_win('group_goods_list', 'widget://html/goods/group_goods_list.html', false)
				}
				//	资讯	会员秀
				if (vo.flag == 6 || vo.flag == 7) {
					openWin_circle_details(vo.url)
				}



				// 无外部链接的情况
				// 1.无链接

			},
			showIcon() {
				var top = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
				if (top > 60) {
					document.querySelector(".aui-bar-nav").style.background = "#005a93"


				} else if (top < 90) {
					document.querySelector(".aui-bar-nav").style.background = "transparent"

					// $api.setStorage('show_type_id', this.currentShow)
				}


			},
			get_banner: function () {
				setTimeout(function () {
					var swiper = new Swiper('.swiper-container', {
						pagination: '.swiper-pagination',
						autoplay: true, //可选选项，自动滑动
						loop: true, //可选选项，是否循环
						autoplay: 5000, //可选选项，自动滑动
						autoplayDisableOnInteraction: false, //注意此参数，默认为true
						mode: 'horizontal',
						freeMode: false,
						followFinger: false,
						observer: true, //修改swiper自己或子元素时，自动初始化swiper
						observeParents: true, //修改swiper的父元素时，自动初始化swiper
					});
				}, 100)
			},
			get_list: function () {
				// alert(JSON.stringify(vm.localcity.categoryname))
				// var region_name = vm.localcity;
				//region_name:region_name
				if (!vm.localcity) {
					return
				}

				// alert(vm.localcity.categoryname)
				get_data('api/home/home', {
					region_name: vm.localcity.categoryname,
					token: $api.getStorage('token'),
				}, function (ret) {
					if (ret.status) {
						// alert(JSON.stringify(ret.data.xp_good))
						console.log(JSON.stringify(ret.data.good_sign));
						vm.index_bg = ret.data.index_bg;
						vm.banner_ad = ret.data.banner_ad.length == 0 ? [{
							"pic": '../image/temp/8@3x.png'
						}] : ret.data.banner_ad
						vm.index_ad = ret.data.index_ad.length == 0 ? [{
							"pic": '../image/temp/81@3x.png'
						}, {
							"pic": '../image/temp/82@3x.png'
						}] : ret.data.index_ad
						vm.xp_good = ret.data.xp_good
						vm.qc_good = ret.data.qc_good
						vm.jp_good = ret.data.jp_good
						vm.good_type = ret.data.good_type
						vm.has_tuan = ret.data.has_tuan
						vm.has_miao = ret.data.has_miao
						// console.log(JSON.stringify(vm.xp_good));
						// console.log(JSON.stringify(vm.qc_good));
						// console.log(JSON.stringify(vm.jp_good));

					}
				})
			},
			price_format: function (type, price) {
				var status = (price + '').indexOf('.')
				if (status == '-1') {
					if (type == 'yuan') {
						return price;
					}
					if (type == 'fen') {
						return '00';
					}
				}
				var price_array = (price + '').split('.')
				if (type == 'yuan') {
					return price_array[0];
				}
				if (type == 'fen') {
					var price_fen = price_array[1].length < 2 ? price_array[1] + '0' : price_array[1];
					return price_fen;
				}
			}
		},
		filters: {
			valueSlice(value) {
				return value.slice(0, 25) + '...'
			}
		},

	})

	apiready = function () {

		vm.agree = api.getPrefs({ sync: true, key: 'agree' });

		

		var temp_localcity = api.getPrefs({
			sync: true,
			key: 'localcity'
		});

		if (temp_localcity) {
			vm.localcity = JSON.parse(temp_localcity);
		}

		console.log(JSON.stringify(vm.localcity))

		api.addEventListener({
			name: 'jobRefresh'
		}, function (ret, err) {
			// alert(JSON.stringify(ret))
			localcity(function (ret) {
				// console.log(999)
				console.log(JSON.stringify(ret))
				if (ret) {
					vm.localcity = ret;
					vm.get_list()
				}
			})
		});

		// if (!vm.localcity) {
		// 	localcity(function (ret) {
		// 		console.log(JSON.stringify(ret))
		// 		if (ret) {
		// 			vm.localcity = ret;
		// 			vm.get_list()
		// 		}
		// 	})
		// }



		// 判断是否有网络
		// isOnLineStatus()
		vm.get_list()
		vm.get_banner()
		// 新版刷新
		// refresh_new(function () {
		// 	setTimeout(function () {
		// 		vm.get_list()
		// 		api.refreshHeaderLoadDone()
		// 	}, 1000)
		// })

		// fnInitPullRefresh(function() {
		vm.loadmore = true
		vm.get_list();
		authToken();
		// api.refreshHeaderLoadDone();

		// })



		add_event('goodsref', function () {
			vm.get_list()
		})
		add_event('loginout', function (ret) {
			vm.login_status = false
		})
		add_event('logined', function (ret) {
			vm.login_status = true
		})
		add_event('remind_add', function (ret) {
			remind()
		})
		add_event('goto_miaosha', function (ret) {
			open_win('miaosha_goods_list', 'goods/miaosha_goods_list.html', false);
			remind()
		})

		add_event('return_index', function (ret) {
			// tapindex(ret.index)
		})

		authToken();
		add_event('read_msg_all', function (ret) {
			// alert(JSON.stringify(ret,null,2))
			vm.unread_msg_num = 0

		})

		remind()

		if (vm.agree == false) {
			// 监听勾选
			vm.openMsgbox()
			return;
		}

		checkUpdate()

	};

	function checkUpdate() {
            var mam = api.require('mam');
            mam.checkUpdate(function(ret, err) {
                if (ret) {
                    var result = ret.result;
					console.log(result)
					if (api.systemType == "ios") {
						if (result.update == true && result.closed == false) {
							var str = '新版本型号:' + result.version + '\r\n发布时间:' + result.time;
							api.confirm({
								title : '有新版本啦！为了您有更好的体验，请务必更新！',
								msg : str,
								buttons : ['稍后升级', '确定']
							}, function(ret, err) {
								console.log(ret.buttonIndex)
								if (ret.buttonIndex == 2) {
									if (api.systemType == "android") {
										api.download({
											url : result.source,
											report : true
										}, function(ret, err) {
											if (ret && 0 == ret.state) {/* 下载进度 */
												api.toast({
													msg : "正在下载应用" + ret.percent + "%",
													duration : 2000
												});
											}
											if (ret && 1 == ret.state) {/* 下载完成 */
												var savePath = ret.savePath;
												api.installApp({
													appUri : savePath
												});
											}
										});
									}
									if (api.systemType == "ios") {
										api.installApp({
											appUri : result.source
										});
									}
								}
							});
						} else {
							// api.alert({
							//     msg : "暂无更新"
							// });
						}
						}else{
							 if (result.update == true && result.closed == false) {
								var str = '新版本型号:' + result.version + '\r\n发布时间:' + result.time;
								api.confirm({
									title : '有新版本啦！为了您有更好的体验，请务必更新！',
									msg : str,
									buttons : ['确定', '稍后升级']
								}, function(ret, err) {
									console.log(ret.buttonIndex)
									if (ret.buttonIndex == 1) {
										if (api.systemType == "android") {
											api.download({
												url : result.source,
												report : true
											}, function(ret, err) {
												if (ret && 0 == ret.state) {/* 下载进度 */
													api.toast({
														msg : "正在下载应用" + ret.percent + "%",
														duration : 2000
													});
												}
												if (ret && 1 == ret.state) {/* 下载完成 */
													var savePath = ret.savePath;
													api.installApp({
														appUri : savePath
													});
												}
											});
										}
										if (api.systemType == "ios") {
											api.installApp({
												appUri : result.source
											});
										}
									}
								});
							} else {
								// api.alert({
								//     msg : "暂无更新"
								// });
							}
						}
                } else {
                    // api.alert({
                    //     msg : err.msg
                    // });
                }
            });
        }

	function open_location() {
		open_win('city_local_win', 'widget://html/page/city_local_win.html', false)
	}

	function open_class_goods_list(id) {
		$api.setStorage('good_type_id', id);
		// if (id == 31) {
		// 	openWin_goods_list_type('限时');
		// } else if (id == 32) {
		// 	openWin_goods_list_type('新品');
		// } else {
		send_event('class_switch', {
			id: id
		})
		send_event('return_index', {
			index: 1
		})
		// }
		// if (id == 33) {
		// 	// openWin_order_list("最近订购");
		// 	openWin_goods_list_type('最近订购');
		// }
		// if (id == 32) {
		// 	openWin_goods_list_type('新品');
		// }
		// open_win('goods_list', 'goods/goods_list.html', false)

	}

	function refresh_network() {
		// vm.get_list()
		var flag = true;

		function once() {
			if (flag) {
				window.location.reload()
				flag = false;
			} else {
				return;
			}
		}
		once();
		send_event('reflesh_network');
	}

	function open_message() {
		if (vm.login_status) {
			openWin_message()
		} else {
			openWin_login()
		}
	}

	/**
	 * 返回当前是否联网
	 * 周枫
	 * 3g 4g wifi none
	 * 2016.11.21
	 */
	function isOnLineStatus(callback) {
		var s = api.connectionType;
		var count = 0;
		s = s.toLowerCase();
		if ((s.indexOf('wifi') != -1) || (s.indexOf('3g') != -1) || (s.indexOf('4g') != -1) || (s.indexOf('2g') != -1)) {
			//callback(true, s);
			vm.isnetwork = true

		} else {
			vm.isnetwork = false
		}
	}









	function remind() {
		var data = $api.getStorage('remind')

		console.log(JSON.stringify(data))
		if (!data || data.length == 0) {
			$api.rmStorage('remind')
			log('暂无提醒')
			return;
		}
		clearTimeout(timeset)
		data = data.sort(compare('time'))
		var nowtime = Date.parse(new Date()) / 1000
		var newdata = [];
		data.forEach(function (el, index) {
			if (nowtime < el.time) {
				newdata.push(el)
			}
		})
		if (newdata.length == 0) {
			$api.rmStorage('remind')
			log('提醒都过期了')
			return;
		}
		var lefttime = (newdata[0].time - nowtime) * 1000;

		timeset = setTimeout(function () {
			api.closeToWin({
				name: 'root'
			});
			setTimeout(function () {
				api.openFrame({
					name: 'remind',
					url: 'remind.html',
					bounces: false,
					rect: {
						x: 0,
						y: 0,
						w: 'auto',
						h: 'auto'
					},
					vScrollBarEnabled: false,
					bgColor: 'rgba(0,0,0,0)'
				})
			}, 300)
		}, lefttime)
		$api.setStorage('remind', newdata)


	}



	function authToken() {
		if ($api.getStorage('token')) {
			get_data('api/login/isToken', {
				token: $api.getStorage('token')
			}, function (ret) {

				if (ret.status == '0') {
					$api.rmStorage('token')
					send_event('loginout')
					// openWin_login()
				}
				if (ret.status == '1') {
					vm.login_status = true
					// alert(JSON.stringify(ret.data))
					vm.unread_msg_num = ret.data.unread_msg_num
					if (ret.data.unread_msg_num == 0) {
						send_event('read_msg_all')
					}
				}
			})
		} else {
			// openWin_login()
		}
	}
</script>

</html>